package com.hx.demo.controller;


import com.hx.demo.domain.User;
import com.hx.demo.service.IUserSeervice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@Controller
@RequestMapping("/admin")
public class IndexController {

    @Autowired
    private IUserSeervice userSeervice;

    @RequestMapping("/index")
    public String index(HttpServletRequest request, Model model){
        //获取用户的登录的信息
        User user = (User) SecurityContextHolder.getContext().getAuthentication() .getPrincipal();
        model.addAttribute("user",user);
        return "/index";
    }

    @RequestMapping("/welcome")
    public String welcomeHtml(){
        return "/welcome";
    }
    @RequestMapping("/ulist")
    public String ulist(){
        return "user_list";
    }

}
